﻿/*
  @Description:客源中跟进记录搜索js
  @Author:zb,yangpl
  @Date:2014-06-30 
*/
$(function () {
    var SearchRank = 0;
    if (customerRight.CheckRight("Customer.Inquiry.Search-All")) {
        SearchRank = 1;
    }
    else if (customerRight.CheckRight("Customer.Inquiry.MyDepartment")) {
        SearchRank = 3;
    }
    else if (customerRight.CheckRight("Customer.Inquiry.MySelf")) {
        SearchRank = 4;
    }
    EmployeePrompt.getDepartAndEmployeeByInput('txtDepartmentName', 'hidDepartmentKeyId', 'txtEmployeeName', 'txtEmployeeKeyId', false, 'private', SearchRank, '请输入业务姓名', '请输入部门名称', true);
    dataBind.bindOption(60, '#selFollowType');
    dataBind.bindOption(45, '#inquiryTradeTypeKeyId');//客源交易类型
    $("#searchForm input[type='reset']").bind("click", function () {
        var temf = $("#txtDateTimeFrom1").val();
        var temt = $("#txtDateTimeTo1").val();
        if (temf != "" && temt != "") {
            if (timehelper.parseDate(temf) > timehelper.parseDate(temt)) {
                $("#txtDateTimeTo1").val(temf);
                $("#txtDateTimeFrom1").val(temt);
            }
        }
         temf = $("#txtDateTimeFrom2").val();
         temt = $("#txtDateTimeTo2").val();
        if (temf != "" && temt != "") {
            if (timehelper.parseDate(temf) > timehelper.parseDate(temt)) {
                $("#txtDateTimeTo2").val(temf);
                $("#txtDateTimeFrom2").val(temt);
            }
        }
    });
    //浮动的工具栏 yjj添加
    var state1 = true; //存储顶部显示的状态
    $(window).scroll(function () {
        if ($(window).scrollTop() > $("#ajaxPages").offset().top) {
            if (state1) {
                //执行浮动层出现后的代码
                $("#editToolsBox").addClass("float-edit-toos");
                //表头排序
                $('.fixed-div div').find(".fixed-span").unbind("click");
                $('.fixed-div div').find(".fixed-span").click(function () {
                    var resultVal = $(this).attr('callValue');
                    if (resultVal) {
                        $('#hiddenSortValue').val(resultVal);
                        $('#searchForm').submit();
                    }
                });

                $(".fixed-div").show();
                $("#gdIndexCustomerList .thead").css("visibility", "hidden");
                $("#thead .last").css("width", "100px");
            }
            state1 = false;
        } else {
            if (!state1) {
                //执行浮动层出现前的代码
                $("#editToolsBox").removeClass("float-edit-toos");
                $(".fixed-div").hide();
                $("#gdIndexCustomerList .thead").css("visibility", "visible");
                $("#thead .last").css("width", "100px");
            }
            state1 = true;
        }
        $(".tab-panel-wrapper").scroll(function () {
            var l = $(".tab-panel-wrapper").scrollLeft();
            $(".fixed-div div").css("margin-left", "-" + l + "px");
        });
    });
});
